/****************************************************************************\
 * @file    key.c
 * @author  马新硕
 * @date    2022/09/20
 * @brief   按键中断
 * @note    
 ******************************************************************************
 * @attent  
 ****************************************************************************/
#include "key.h"
#include "main.h"
#include "freertos.h"
#include "cmsis_os2.h"
#include "game_pic.h"

extern osMessageQueueId_t UsersbulletQueueHandle;//消息队列句柄
static void Key_Delay ( __IO uint32_t nCount );

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  uint8_t add_usersbullet = 1;
  if(GPIO_Pin == KEY1_Pin)
  {
    Key_Delay(3000);
    if(HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin) == SET)
      osMessageQueuePut(UsersbulletQueueHandle, &add_usersbullet, 1, 0);
  //     if(HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin) == SET)
  //       Pic_1.Vertec_x += 10;
  }
  if(GPIO_Pin == KEY2_Pin)
  {
    Key_Delay(3000);
    if(HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin) == SET)
    {
      Knight.Vertec_y += 10;
      Knight.Center_y += 10;
    }
  }
}


static void Key_Delay ( __IO uint32_t nCount )
{
  for ( ; nCount != 0; nCount -- );
	
}
